package com.ly.tast;

import com.ly.base.HouseStatus;
import com.ly.entity.House;
import com.ly.repository.HouseRepository;
import com.ly.service.search.HouseIndexTemplate;
import com.ly.service.search.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 批量更新es索引
 * @author ：LY
 * @date ：Created in 2020/11/20 17:44
 * @modified By：
 */
@Service
public class updateIndex {
    @Autowired
    private HouseRepository houseRepository;
    @Autowired
    private ISearchService searchService;

    public  void update(){
        Iterable<House> houses = houseRepository.findAll();
        houses.forEach(house -> {
            if (house.getStatus() == HouseStatus.PASSES.getValue())
                    searchService.index(house.getId());
        });
    }

}
